package cn.train.controler;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.train.service.AddTrain;
@WebServlet("/CheckTrainServlet")
public class CheckTrainServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String trainname=req.getParameter("trainname");
		AddTrain at = new AddTrain();
		int flag=at.lookcarname(trainname);
		PrintWriter out = resp.getWriter();
		if(flag==1) {
			out.print(1);
		}else {
			out.print(0);
		}
	    
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(req, resp);
	}

}
